<template>
    <div>


      <div style="width: 92%;margin: auto">
        <p class="p1">添加评论</p>
        <textarea placeholder="期待您对课程做出中肯的评价哦~" maxlength='200' v-model="text">
        </textarea>
				<p class="textright">{{text.length}}/200</p>
      </div>
      <van-button type="info" class="tijiao" @click="t()">确认提交</van-button>

    </div>
</template>

<script>
    export default {
        name: "Pl",
      data(){
          return{
						id:'',
            text:'',
						type:'',
          }
      },
      methods:{
        t(){
					var type = this.$route.query.type;
					var comm = this.text;
					var name = comm.replace(/\s+/g, "");
					if(name==''){
						this.$toast({
						  message:'说点什么吧!!!',
						  position:'bottom'
						});
					}else{
						if(type == 3||type == '3'){
							var url=this.$store.state.url + "Classroom/comment";
						}else if(type == 2||type == '2'){
							var url=this.$store.state.url + "LiveSpec/comment";
						}else if(type == 1||type == '1'){
							var url=this.$store.state.url + "LiveCourse/comment";
						}
						// var name1 = Base64.encode(name);
						// console.log(Base64.encode(name));
						// console.log(Base64.decode(name1));
						this.axios.post(url,{
							id:this.$route.query.id,
							content:Base64.encode(name)
						}).then(res=>{
             // console.log(res.data)
             if (res.data.errcode == 0||res.data.errcode == '0'){
							 var that = this;
							 setTimeout(function(){
                 that.$router.go(-1);
							 })
             }else {
               this.$toast({
                 message:res.data.msg,
               });
             }
           })
					}
        }
      },
      mounted(){
				this.sdk.getJSSDK('','',this.$store.state.url);	
         this.type=this.$route.query.type;
         this.id=this.$route.query.id;
      }
    }
</script>

<style scoped>
		.textright{
			margin-top: .2rem;
			color: #999;
			font-size: .28rem;
			text-align: right;
		}
    .p1{
      font-size:0.34rem;
      font-weight:bold;
      color:rgba(51,51,51,1);
      line-height:0.32rem;
      margin-top: 0.5rem;
    }
    textarea{
    width: 100%;
    border: none;
    height:3.67rem;
    background:rgba(247,247,247,1);
    border-radius:0.1rem;
    margin-top: 0.3rem;
    overflow: hidden;
    text-indent: 0.3rem;
    /* padding-top: 0.2rem; */
		padding: .3rem;
  }

    textarea::placeholder{
    font-size: 0.28rem;
    font-weight:400;
    color:rgba(153,153,153,1);
    line-height:0.32rem;
    margin-top: 0.2rem;
  }
    input,button,select,textarea{outline:none}
    textarea{resize:none}
  .tijiao{
    width: 100%;
    height: 0.7rem;
    font-size:0.28rem;
    line-height: 0.7rem;
    background:rgba(2,135,255,1);
    position: absolute;
    bottom: 0;
  }
</style>
